﻿<html><body style='font-size:11px; color:#000000; background:#ffffff; '><pre>
<span style='color:#800000; font-weight:bold; '>Private</span> <span style='color:#800000; font-weight:bold; '>Sub</span> createPdfButton_Click<span style='color:#808030; '>(</span><span style='color:#800000; font-weight:bold; '>ByVal</span> sender <span style='color:#800000; font-weight:bold; '>As</span> <span style='color:#800000; font-weight:bold; '>Object</span><span style='color:#808030; '>,</span> <span style='color:#800000; font-weight:bold; '>ByVal</span> e <span style='color:#800000; font-weight:bold; '>As</span> EventArgs<span style='color:#808030; '>)</span> <span style='color:#800000; font-weight:bold; '>Handles</span> createPdfButton<span style='color:#008c00; '>.</span>Click
    <span style='color:#696969; '>' Create a PDF document</span>
    <span style='color:#800000; font-weight:bold; '>Dim</span> pdfDocument <span style='color:#800000; font-weight:bold; '>As</span> <span style='color:#800000; font-weight:bold; '>New</span> Document<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span>

    <span style='color:#696969; '>' Set license key received after purchase to use the converter in licensed mode</span>
    <span style='color:#696969; '>' Leave it not set to use the converter in demo mode</span>
    pdfDocument<span style='color:#008c00; '>.</span>LicenseKey <span style='color:#808030; '>=</span> <span style='color:#0000e6; '>"4W9+bn19bn5ue2B+bn1/YH98YHd3d3c="</span>

    <span style='color:#696969; '>' Display the bookmarks panel when the PDF document is opened in a PDF viewer</span>
    pdfDocument<span style='color:#008c00; '>.</span>ViewerPreferences<span style='color:#008c00; '>.</span>PageMode <span style='color:#808030; '>=</span> ViewerPageMode<span style='color:#008c00; '>.</span>UseOutlines

    Cursor <span style='color:#808030; '>=</span> Cursors<span style='color:#008c00; '>.</span>WaitCursor
    <span style='color:#800000; font-weight:bold; '>Dim</span> outPdfFile <span style='color:#800000; font-weight:bold; '>As</span> <span style='color:#800000; font-weight:bold; '>String</span> <span style='color:#808030; '>=</span> <span style='color:#0000e6; '>"DemoAppFiles\Output\PDF_Creator\Bookmarks.pdf"</span>
    <span style='color:#800000; font-weight:bold; '>Try</span>
        <span style='color:#696969; '>' The titles font used to mark various sections of the PDF document</span>
        <span style='color:#800000; font-weight:bold; '>Dim</span> titleFont <span style='color:#800000; font-weight:bold; '>As</span> PdfFont <span style='color:#808030; '>=</span> pdfDocument<span style='color:#008c00; '>.</span>AddFont<span style='color:#808030; '>(</span><span style='color:#800000; font-weight:bold; '>New</span> Font<span style='color:#808030; '>(</span><span style='color:#0000e6; '>"Times New Roman"</span><span style='color:#808030; '>,</span> <span style='color:#008c00; '>12</span><span style='color:#808030; '>,</span> FontStyle<span style='color:#008c00; '>.</span>Regular<span style='color:#808030; '>,</span> GraphicsUnit<span style='color:#008c00; '>.</span>Point<span style='color:#808030; '>)</span><span style='color:#808030; '>)</span>

        <span style='color:#696969; '>' Add a new PDF page to PDF document</span>
        <span style='color:#800000; font-weight:bold; '>Dim</span> page1 <span style='color:#800000; font-weight:bold; '>As</span> PdfPage <span style='color:#808030; '>=</span> pdfDocument<span style='color:#008c00; '>.</span>AddPage<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span>
        <span style='color:#800000; font-weight:bold; '>Dim</span> pageText <span style='color:#800000; font-weight:bold; '>As</span> <span style='color:#800000; font-weight:bold; '>New</span> TextElement<span style='color:#808030; '>(</span><span style='color:#008c00; '>0</span><span style='color:#808030; '>,</span> <span style='color:#008c00; '>0</span><span style='color:#808030; '>,</span> <span style='color:#0000e6; '>"Page 1. Destination of a Top Bookmark with Fit Width View Mode."</span><span style='color:#808030; '>,</span> titleFont<span style='color:#808030; '>)</span>
        page1<span style='color:#008c00; '>.</span>AddElement<span style='color:#808030; '>(</span>pageText<span style='color:#808030; '>)</span>

        <span style='color:#696969; '>' Add a new PDF page to PDF document</span>
        <span style='color:#800000; font-weight:bold; '>Dim</span> page2 <span style='color:#800000; font-weight:bold; '>As</span> PdfPage <span style='color:#808030; '>=</span> pdfDocument<span style='color:#008c00; '>.</span>AddPage<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span>
        pageText <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>New</span> TextElement<span style='color:#808030; '>(</span><span style='color:#008c00; '>0</span><span style='color:#808030; '>,</span> <span style='color:#008c00; '>0</span><span style='color:#808030; '>,</span> <span style='color:#0000e6; '>"Page 2. Destination of a Top Bookmark with Custom Zoom Level."</span><span style='color:#808030; '>,</span> titleFont<span style='color:#808030; '>)</span>
        page2<span style='color:#008c00; '>.</span>AddElement<span style='color:#808030; '>(</span>pageText<span style='color:#808030; '>)</span>

        <span style='color:#696969; '>' Add a new PDF page to PDF document</span>
        <span style='color:#800000; font-weight:bold; '>Dim</span> page3 <span style='color:#800000; font-weight:bold; '>As</span> PdfPage <span style='color:#808030; '>=</span> pdfDocument<span style='color:#008c00; '>.</span>AddPage<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span>
        pageText <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>New</span> TextElement<span style='color:#808030; '>(</span><span style='color:#008c00; '>0</span><span style='color:#808030; '>,</span> <span style='color:#008c00; '>0</span><span style='color:#808030; '>,</span> <span style='color:#0000e6; '>"Page 3. Destination of a Child Bookmark with Fit Width and Height View Mode."</span><span style='color:#808030; '>,</span> titleFont<span style='color:#808030; '>)</span>
        page3<span style='color:#008c00; '>.</span>AddElement<span style='color:#808030; '>(</span>pageText<span style='color:#808030; '>)</span>

        <span style='color:#696969; '>' Add a new PDF page to PDF document</span>
        <span style='color:#800000; font-weight:bold; '>Dim</span> page4 <span style='color:#800000; font-weight:bold; '>As</span> PdfPage <span style='color:#808030; '>=</span> pdfDocument<span style='color:#008c00; '>.</span>AddPage<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span>
        pageText <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>New</span> TextElement<span style='color:#808030; '>(</span><span style='color:#008c00; '>0</span><span style='color:#808030; '>,</span> <span style='color:#800000; font-weight:bold; '>CLng</span><span style='color:#808030; '>(</span>page4<span style='color:#008c00; '>.</span>PageSize<span style='color:#008c00; '>.</span>Height<span style='color:#808030; '>)</span> \ <span style='color:#008c00; '>2</span> <span style='color:#808030; '>-</span> <span style='color:#008c00; '>20</span><span style='color:#808030; '>,</span> <span style='color:#0000e6; '>"Page 4. Destination of a Top Bookmark for the Middle of the Page."</span><span style='color:#808030; '>,</span> titleFont<span style='color:#808030; '>)</span>
        page4<span style='color:#008c00; '>.</span>AddElement<span style='color:#808030; '>(</span>pageText<span style='color:#808030; '>)</span>

        <span style='color:#696969; '>' Add a new PDF page to PDF document</span>
        <span style='color:#800000; font-weight:bold; '>Dim</span> page5 <span style='color:#800000; font-weight:bold; '>As</span> PdfPage <span style='color:#808030; '>=</span> pdfDocument<span style='color:#008c00; '>.</span>AddPage<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span>
        pageText <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>New</span> TextElement<span style='color:#808030; '>(</span><span style='color:#008c00; '>0</span><span style='color:#808030; '>,</span> <span style='color:#008c00; '>0</span><span style='color:#808030; '>,</span> <span style='color:#0000e6; '>"Page 5. Destination of a Child Bookmark with Colored Title."</span><span style='color:#808030; '>,</span> titleFont<span style='color:#808030; '>)</span>
        page5<span style='color:#008c00; '>.</span>AddElement<span style='color:#808030; '>(</span>pageText<span style='color:#808030; '>)</span>

        <span style='color:#696969; '>' Add a new PDF page to PDF document</span>
        <span style='color:#800000; font-weight:bold; '>Dim</span> page6 <span style='color:#800000; font-weight:bold; '>As</span> PdfPage <span style='color:#808030; '>=</span> pdfDocument<span style='color:#008c00; '>.</span>AddPage<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span>
        pageText <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>New</span> TextElement<span style='color:#808030; '>(</span><span style='color:#008c00; '>0</span><span style='color:#808030; '>,</span> <span style='color:#008c00; '>0</span><span style='color:#808030; '>,</span> <span style='color:#0000e6; '>"Page 6. Destination of a Child Bookmark with Italic Style Title."</span><span style='color:#808030; '>,</span> titleFont<span style='color:#808030; '>)</span>
        page6<span style='color:#008c00; '>.</span>AddElement<span style='color:#808030; '>(</span>pageText<span style='color:#808030; '>)</span>

        <span style='color:#696969; '>' Add a top level bookmark for first page setting destination view mode to fit viewer window horizontally</span>
        <span style='color:#800000; font-weight:bold; '>Dim</span> page1Destination <span style='color:#800000; font-weight:bold; '>As</span> <span style='color:#800000; font-weight:bold; '>New</span> ExplicitDestination<span style='color:#808030; '>(</span>page1<span style='color:#808030; '>,</span> <span style='color:#800000; font-weight:bold; '>New</span> PointF<span style='color:#808030; '>(</span><span style='color:#008c00; '>0</span><span style='color:#808030; '>,</span> <span style='color:#008c00; '>0</span><span style='color:#808030; '>)</span><span style='color:#808030; '>,</span> DestinationViewMode<span style='color:#008c00; '>.</span>FitH<span style='color:#808030; '>)</span>
        <span style='color:#800000; font-weight:bold; '>Dim</span> page1TopBookmark <span style='color:#800000; font-weight:bold; '>As</span> Bookmark <span style='color:#808030; '>=</span> pdfDocument<span style='color:#008c00; '>.</span>Bookmarks<span style='color:#008c00; '>.</span>AddNewBookmark<span style='color:#808030; '>(</span><span style='color:#0000e6; '>"Top Bookmark with Fit Width View Mode"</span><span style='color:#808030; '>,</span> page1Destination<span style='color:#808030; '>)</span>
        page1TopBookmark<span style='color:#008c00; '>.</span>Style <span style='color:#808030; '>=</span> PdfBookmarkStyle<span style='color:#008c00; '>.</span>Bold

        <span style='color:#696969; '>' Add a top level bookmark for second page setting the zoom level to 125%</span>
        <span style='color:#800000; font-weight:bold; '>Dim</span> page2Destination <span style='color:#800000; font-weight:bold; '>As</span> <span style='color:#800000; font-weight:bold; '>New</span> ExplicitDestination<span style='color:#808030; '>(</span>page2<span style='color:#808030; '>,</span> <span style='color:#800000; font-weight:bold; '>New</span> PointF<span style='color:#808030; '>(</span><span style='color:#008c00; '>0</span><span style='color:#808030; '>,</span> <span style='color:#008c00; '>0</span><span style='color:#808030; '>)</span><span style='color:#808030; '>,</span> DestinationViewMode<span style='color:#008c00; '>.</span>XYZ<span style='color:#808030; '>)</span>
        page2Destination<span style='color:#008c00; '>.</span>ZoomPercentage <span style='color:#808030; '>=</span> <span style='color:#008c00; '>125</span>
        <span style='color:#800000; font-weight:bold; '>Dim</span> page2TopBookmark <span style='color:#800000; font-weight:bold; '>As</span> Bookmark <span style='color:#808030; '>=</span> pdfDocument<span style='color:#008c00; '>.</span>Bookmarks<span style='color:#008c00; '>.</span>AddNewBookmark<span style='color:#808030; '>(</span><span style='color:#0000e6; '>"Top Bookmark with Custom Zoom Level"</span><span style='color:#808030; '>,</span> page2Destination<span style='color:#808030; '>)</span>
        page2TopBookmark<span style='color:#008c00; '>.</span>Style <span style='color:#808030; '>=</span> PdfBookmarkStyle<span style='color:#008c00; '>.</span>Normal

        <span style='color:#696969; '>' Add a child bookmark for third page setting destination view mode to fit viewer window horizontally and vertically</span>
        <span style='color:#800000; font-weight:bold; '>Dim</span> page3Destination <span style='color:#800000; font-weight:bold; '>As</span> <span style='color:#800000; font-weight:bold; '>New</span> ExplicitDestination<span style='color:#808030; '>(</span>page3<span style='color:#808030; '>,</span> <span style='color:#800000; font-weight:bold; '>New</span> PointF<span style='color:#808030; '>(</span><span style='color:#008c00; '>0</span><span style='color:#808030; '>,</span> <span style='color:#008c00; '>0</span><span style='color:#808030; '>)</span><span style='color:#808030; '>,</span> DestinationViewMode<span style='color:#008c00; '>.</span>Fit<span style='color:#808030; '>)</span>
        <span style='color:#800000; font-weight:bold; '>Dim</span> page3ChildBookmark <span style='color:#800000; font-weight:bold; '>As</span> Bookmark <span style='color:#808030; '>=</span> page2TopBookmark<span style='color:#008c00; '>.</span>DescendantBookmarks<span style='color:#008c00; '>.</span>AddNewBookmark<span style='color:#808030; '>(</span><span style='color:#0000e6; '>"Child Bookmark with Fit Width and Height View Mode"</span><span style='color:#808030; '>,</span> page3Destination<span style='color:#808030; '>)</span>

        <span style='color:#696969; '>' Add a top level bookmark for fourth page with destination point in the middle of the PDF page </span>
        <span style='color:#800000; font-weight:bold; '>Dim</span> page4Destination <span style='color:#800000; font-weight:bold; '>As</span> <span style='color:#800000; font-weight:bold; '>New</span> ExplicitDestination<span style='color:#808030; '>(</span>page4<span style='color:#808030; '>,</span> <span style='color:#800000; font-weight:bold; '>New</span> PointF<span style='color:#808030; '>(</span><span style='color:#008c00; '>0</span><span style='color:#808030; '>,</span> <span style='color:#800000; font-weight:bold; '>CLng</span><span style='color:#808030; '>(</span>page4<span style='color:#008c00; '>.</span>PageSize<span style='color:#008c00; '>.</span>Height<span style='color:#808030; '>)</span> \ <span style='color:#008c00; '>2</span> <span style='color:#808030; '>-</span> <span style='color:#008c00; '>20</span><span style='color:#808030; '>)</span><span style='color:#808030; '>)</span>
        <span style='color:#800000; font-weight:bold; '>Dim</span> page4TopBookmark <span style='color:#800000; font-weight:bold; '>As</span> Bookmark <span style='color:#808030; '>=</span> pdfDocument<span style='color:#008c00; '>.</span>Bookmarks<span style='color:#008c00; '>.</span>AddNewBookmark<span style='color:#808030; '>(</span><span style='color:#0000e6; '>"Top Bookmark for the Middle of the Page"</span><span style='color:#808030; '>,</span> page4Destination<span style='color:#808030; '>)</span>
        page4TopBookmark<span style='color:#008c00; '>.</span>Style <span style='color:#808030; '>=</span> PdfBookmarkStyle<span style='color:#008c00; '>.</span>Bold
        page4TopBookmark<span style='color:#008c00; '>.</span>Color <span style='color:#808030; '>=</span> Color<span style='color:#008c00; '>.</span>Blue

        <span style='color:#696969; '>' Add a child bookmark with colored text</span>
        <span style='color:#800000; font-weight:bold; '>Dim</span> page5Destination <span style='color:#800000; font-weight:bold; '>As</span> <span style='color:#800000; font-weight:bold; '>New</span> ExplicitDestination<span style='color:#808030; '>(</span>page5<span style='color:#808030; '>,</span> <span style='color:#800000; font-weight:bold; '>New</span> PointF<span style='color:#808030; '>(</span><span style='color:#008c00; '>0</span><span style='color:#808030; '>,</span> <span style='color:#008c00; '>0</span><span style='color:#808030; '>)</span><span style='color:#808030; '>)</span>
        <span style='color:#800000; font-weight:bold; '>Dim</span> page5ChildBookmark <span style='color:#800000; font-weight:bold; '>As</span> Bookmark <span style='color:#808030; '>=</span> page4TopBookmark<span style='color:#008c00; '>.</span>DescendantBookmarks<span style='color:#008c00; '>.</span>AddNewBookmark<span style='color:#808030; '>(</span><span style='color:#0000e6; '>"Child Bookmark with Colored Title"</span><span style='color:#808030; '>,</span> page5Destination<span style='color:#808030; '>)</span>
        page5ChildBookmark<span style='color:#008c00; '>.</span>Color <span style='color:#808030; '>=</span> Color<span style='color:#008c00; '>.</span>Red

        <span style='color:#696969; '>' Add a child bookmark with italic style text</span>
        <span style='color:#800000; font-weight:bold; '>Dim</span> page6Destination <span style='color:#800000; font-weight:bold; '>As</span> <span style='color:#800000; font-weight:bold; '>New</span> ExplicitDestination<span style='color:#808030; '>(</span>page6<span style='color:#808030; '>,</span> <span style='color:#800000; font-weight:bold; '>New</span> PointF<span style='color:#808030; '>(</span><span style='color:#008c00; '>0</span><span style='color:#808030; '>,</span> <span style='color:#008c00; '>0</span><span style='color:#808030; '>)</span><span style='color:#808030; '>)</span>
        <span style='color:#800000; font-weight:bold; '>Dim</span> page6ChildBookmark <span style='color:#800000; font-weight:bold; '>As</span> Bookmark <span style='color:#808030; '>=</span> page4TopBookmark<span style='color:#008c00; '>.</span>DescendantBookmarks<span style='color:#008c00; '>.</span>AddNewBookmark<span style='color:#808030; '>(</span><span style='color:#0000e6; '>"Child Bookmark with Italic Colored Title"</span><span style='color:#808030; '>,</span> page6Destination<span style='color:#808030; '>)</span>
        page6ChildBookmark<span style='color:#008c00; '>.</span>Style <span style='color:#808030; '>=</span> PdfBookmarkStyle<span style='color:#008c00; '>.</span>Italic
        page6ChildBookmark<span style='color:#008c00; '>.</span>Color <span style='color:#808030; '>=</span> Color<span style='color:#008c00; '>.</span>Green

        <span style='color:#696969; '>' Save the PDF document in a memory buffer</span>
        <span style='color:#800000; font-weight:bold; '>Dim</span> outPdfBuffer<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span> <span style='color:#800000; font-weight:bold; '>As</span> <span style='color:#800000; font-weight:bold; '>Byte</span> <span style='color:#808030; '>=</span> pdfDocument<span style='color:#008c00; '>.</span>Save<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span>

        <span style='color:#696969; '>' Write the memory buffer in a PDF file</span>
        <span style='color:#800000; font-weight:bold; '>System</span><span style='color:#008c00; '>.</span>IO<span style='color:#008c00; '>.</span>File<span style='color:#008c00; '>.</span>WriteAllBytes<span style='color:#808030; '>(</span>outPdfFile<span style='color:#808030; '>,</span> outPdfBuffer<span style='color:#808030; '>)</span>
    <span style='color:#800000; font-weight:bold; '>Catch</span> ex <span style='color:#800000; font-weight:bold; '>As</span> Exception
        <span style='color:#696969; '>' The PDF creation failed</span>
        MessageBox<span style='color:#008c00; '>.</span>Show<span style='color:#808030; '>(</span><span style='color:#800000; font-weight:bold; '>String</span><span style='color:#008c00; '>.</span><span style='color:#800000; font-weight:bold; '>Format</span><span style='color:#808030; '>(</span><span style='color:#0000e6; '>"Create PDF Document Error. {0}"</span><span style='color:#808030; '>,</span> ex<span style='color:#008c00; '>.</span>Message<span style='color:#808030; '>)</span><span style='color:#808030; '>)</span>
        <span style='color:#800000; font-weight:bold; '>Return</span>
    <span style='color:#800000; font-weight:bold; '>Finally</span>
        <span style='color:#696969; '>' Close the PDF document</span>
        pdfDocument<span style='color:#008c00; '>.</span><span style='color:#800000; font-weight:bold; '>Close</span><span style='color:#808030; '>(</span><span style='color:#808030; '>)</span>

        Cursor <span style='color:#808030; '>=</span> Cursors<span style='color:#008c00; '>.</span>Arrow
    <span style='color:#800000; font-weight:bold; '>End</span> <span style='color:#800000; font-weight:bold; '>Try</span>

    <span style='color:#696969; '>' Open the created PDF document in default PDF viewer</span>
    <span style='color:#800000; font-weight:bold; '>Try</span>
        Process<span style='color:#008c00; '>.</span>Start<span style='color:#808030; '>(</span>outPdfFile<span style='color:#808030; '>)</span>
    <span style='color:#800000; font-weight:bold; '>Catch</span> ex <span style='color:#800000; font-weight:bold; '>As</span> Exception
        MessageBox<span style='color:#008c00; '>.</span>Show<span style='color:#808030; '>(</span><span style='color:#800000; font-weight:bold; '>String</span><span style='color:#008c00; '>.</span><span style='color:#800000; font-weight:bold; '>Format</span><span style='color:#808030; '>(</span><span style='color:#0000e6; '>"Cannot open created PDF file '{0}'. {1}"</span><span style='color:#808030; '>,</span> outPdfFile<span style='color:#808030; '>,</span> ex<span style='color:#008c00; '>.</span>Message<span style='color:#808030; '>)</span><span style='color:#808030; '>)</span>
    <span style='color:#800000; font-weight:bold; '>End</span> <span style='color:#800000; font-weight:bold; '>Try</span>
<span style='color:#800000; font-weight:bold; '>End</span> <span style='color:#800000; font-weight:bold; '>Sub</span>
</pre>
</body>
</html>